﻿using HandyControl.Controls;
using Ping9719.WpfEx;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
using System.Windows;
//using System.Windows.Forms;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
using TextBox = System.Windows.Controls.TextBox;

namespace BaseUi.Views.PlcView
{
    /// <summary>
    /// VelocitysetView.xaml 的交互逻辑
    /// </summary>
    public partial class VelocitysetView : UserControlBase
    {
        private IInputElement focusedControl;
        private DispatcherTimer dispatcherTimer = null;

        public VelocitysetView()
        {
            InitializeComponent();
        }
        private void TimeCycle()
        {
            var ioi = LocalStatic.Plc.Read<float>("1128");
            if (ioi.IsSucceed ==false)
            {
                VelocBox1g1.Text = "未接收";
            }
            else
            {
                VelocBox1g1.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1130");
            if (ioi.IsSucceed == false)
            {
                VelocBox2g1.Text = "未接收";
            }
            else
            {
                VelocBox2g1.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1124");
            if (ioi.IsSucceed == false)
            {
                VelocBox3g1.Text = "未接收";
            }
            else
            {
                VelocBox3g1.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1126");
            if (ioi.IsSucceed == false)
            {
                VelocBox4g1.Text = "未接收";
            }
            else
            {
                VelocBox4g1.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1408");
            if (ioi.IsSucceed == false)
            {
                VelocBox5g1.Text = "未接收";
            }
            else
            {
                VelocBox5g1.Text = ioi.Value.ToString();
            }
            //VelocBox1g1.Text = LocalStatic.Plc.Read<float>("1128").Value.ToString();
            //VelocBox2g1.Text = LocalStatic.Plc.Read<float>("1130").Value.ToString();
            //VelocBox3g1.Text = LocalStatic.Plc.Read<float>("1124").Value.ToString();
            //VelocBox4g1.Text = LocalStatic.Plc.Read<float>("1126").Value.ToString();
            //VelocBox5g1.Text = LocalStatic.Plc.Read<float>("1408").Value.ToString();
            ioi = LocalStatic.Plc.Read<float>("1136");
            if (ioi.IsSucceed == false)
            {
                VelocBox1g2.Text = "未接收";
            }
            else
            {
                VelocBox1g2.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1138");
            if (ioi.IsSucceed == false)
            {
                VelocBox2g2.Text = "未接收";
            }
            else
            {
                VelocBox2g2.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1132");
            if (ioi.IsSucceed == false)
            {
                VelocBox3g2.Text = "未接收";
            }
            else
            {
                VelocBox3g2.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1134");
            if (ioi.IsSucceed == false)
            {
                VelocBox4g2.Text = "未接收";
            }
            else
            {
                VelocBox4g2.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1410");
            if (ioi.IsSucceed == false)
            {
                VelocBox5g2.Text = "未接收";
            }
            else
            {
                VelocBox5g2.Text = ioi.Value.ToString();
            }
            //VelocBox1g2.Text = LocalStatic.Plc.Read<float>("1136").Value.ToString();
            //VelocBox2g2.Text = LocalStatic.Plc.Read<float>("1138").Value.ToString();
            //VelocBox3g2.Text = LocalStatic.Plc.Read<float>("1132").Value.ToString();
            //VelocBox4g2.Text = LocalStatic.Plc.Read<float>("1134").Value.ToString();
            //VelocBox5g2.Text = LocalStatic.Plc.Read<float>("1410").Value.ToString();
            ioi = LocalStatic.Plc.Read<float>("1144");
            if (ioi.IsSucceed == false)
            {
                VelocBox1g3.Text = "未接收";
            }
            else
            {
                VelocBox1g3.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1146");
            if (ioi.IsSucceed == false)
            {
                VelocBox2g3.Text = "未接收";
            }
            else
            {
                VelocBox2g3.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1140");
            if (ioi.IsSucceed == false)
            {
                VelocBox3g3.Text = "未接收";
            }
            else
            {
                VelocBox3g3.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1142");
            if (ioi.IsSucceed == false)
            {
                VelocBox4g3.Text = "未接收";
            }
            else
            {
                VelocBox4g3.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1412");
            if (ioi.IsSucceed == false)
            {
                VelocBox5g3.Text = "未接收";
            }
            else
            {
                VelocBox5g3.Text = ioi.Value.ToString();
            }
            //VelocBox1g3.Text = LocalStatic.Plc.Read<float>("1144").Value.ToString();
            //VelocBox2g3.Text = LocalStatic.Plc.Read<float>("1146").Value.ToString();
            //VelocBox3g3.Text = LocalStatic.Plc.Read<float>("1140").Value.ToString();
            //VelocBox4g3.Text = LocalStatic.Plc.Read<float>("1142").Value.ToString();
            //VelocBox5g3.Text = LocalStatic.Plc.Read<float>("1412").Value.ToString();
            ioi = LocalStatic.Plc.Read<float>("1156");
            if (ioi.IsSucceed == false)
            {
                VelocBox1g4.Text = "未接收";
            }
            else
            {
                VelocBox1g4.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1158");
            if (ioi.IsSucceed == false)
            {
                VelocBox2g4.Text = "未接收";
            }
            else
            {
                VelocBox2g4.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1148");
            if (ioi.IsSucceed == false)
            {
                VelocBox3g4.Text = "未接收";
            }
            else
            {
                VelocBox3g4.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1154");
            if (ioi.IsSucceed == false)
            {
                VelocBox4g4.Text = "未接收";
            }
            else
            {
                VelocBox4g4.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1414");
            if (ioi.IsSucceed == false)
            {
                VelocBox5g4.Text = "未接收";
            }
            else
            {
                VelocBox5g4.Text = ioi.Value.ToString();
            }
            //VelocBox1g4.Text = LocalStatic.Plc.Read<float>("1156").Value.ToString();
            //VelocBox2g4.Text = LocalStatic.Plc.Read<float>("1158").Value.ToString();
            //VelocBox3g4.Text = LocalStatic.Plc.Read<float>("1148").Value.ToString();
            //VelocBox4g4.Text = LocalStatic.Plc.Read<float>("1154").Value.ToString();
            //VelocBox5g4.Text = LocalStatic.Plc.Read<float>("1414").Value.ToString();
            ioi = LocalStatic.Plc.Read<float>("1164");
            if (ioi.IsSucceed == false)
            {
                VelocBox1g5.Text = "未接收";
            }
            else
            {
                VelocBox1g5.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1166");
            if (ioi.IsSucceed == false)
            {
                VelocBox2g5.Text = "未接收";
            }
            else
            {
                VelocBox2g5.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1160");
            if (ioi.IsSucceed == false)
            {
                VelocBox3g5.Text = "未接收";
            }
            else
            {
                VelocBox3g5.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1162");
            if (ioi.IsSucceed == false)
            {
                VelocBox4g5.Text = "未接收";
            }
            else
            {
                VelocBox4g5.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1416");
            if (ioi.IsSucceed == false)
            {
                VelocBox5g5.Text = "未接收";
            }
            else
            {
                VelocBox5g5.Text = ioi.Value.ToString();
            }
            //VelocBox1g5.Text = LocalStatic.Plc.Read<float>("1164").Value.ToString();
            //VelocBox2g5.Text = LocalStatic.Plc.Read<float>("1166").Value.ToString();
            //VelocBox3g5.Text = LocalStatic.Plc.Read<float>("1160").Value.ToString();
            //VelocBox4g5.Text = LocalStatic.Plc.Read<float>("1162").Value.ToString();
            //VelocBox5g5.Text = LocalStatic.Plc.Read<float>("1416").Value.ToString();
            ioi = LocalStatic.Plc.Read<float>("1104");
            if (ioi.IsSucceed == false)
            {
                VelocBox1g6.Text = "未接收";
            }
            else
            {
                VelocBox1g6.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1106");
            if (ioi.IsSucceed == false)
            {
                VelocBox2g6.Text = "未接收";
            }
            else
            {
                VelocBox2g6.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1100");
            if (ioi.IsSucceed == false)
            {
                VelocBox3g6.Text = "未接收";
            }
            else
            {
                VelocBox3g6.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1102");
            if (ioi.IsSucceed == false)
            {
                VelocBox4g6.Text = "未接收";
            }
            else
            {
                VelocBox4g6.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1400");
            if (ioi.IsSucceed == false)
            {
                VelocBox5g6.Text = "未接收";
            }
            else
            {
                VelocBox5g6.Text = ioi.Value.ToString();
            }
            //VelocBox1g6.Text = LocalStatic.Plc.Read<float>("1104").Value.ToString();
            //VelocBox2g6.Text = LocalStatic.Plc.Read<float>("1106").Value.ToString();
            //VelocBox3g6.Text = LocalStatic.Plc.Read<float>("1100").Value.ToString();
            //VelocBox4g6.Text = LocalStatic.Plc.Read<float>("1102").Value.ToString();
            //VelocBox5g6.Text = LocalStatic.Plc.Read<float>("1400").Value.ToString();
            ioi = LocalStatic.Plc.Read<float>("1604");
            if (ioi.IsSucceed == false)
            {
                VelocBox1g7.Text = "未接收";
            }
            else
            {
                VelocBox1g7.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1606");
            if (ioi.IsSucceed == false)
            {
                VelocBox2g7.Text = "未接收";
            }
            else
            {
                VelocBox2g7.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1600");
            if (ioi.IsSucceed == false)
            {
                VelocBox3g7.Text = "未接收";
            }
            else
            {
                VelocBox3g7.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1602");
            if (ioi.IsSucceed == false)
            {
                VelocBox4g7.Text = "未接收";
            }
            else
            {
                VelocBox4g7.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1402");
            if (ioi.IsSucceed == false)
            {
                VelocBox5g7.Text = "未接收";
            }
            else
            {
                VelocBox5g7.Text = ioi.Value.ToString();
            }
            //VelocBox1g7.Text = LocalStatic.Plc.Read<float>("1604").Value.ToString();
            //VelocBox2g7.Text = LocalStatic.Plc.Read<float>("1606").Value.ToString();
            //VelocBox3g7.Text = LocalStatic.Plc.Read<float>("1600").Value.ToString();
            //VelocBox4g7.Text = LocalStatic.Plc.Read<float>("1602").Value.ToString();
            //VelocBox5g7.Text = LocalStatic.Plc.Read<float>("1402").Value.ToString();

            ioi = LocalStatic.Plc.Read<float>("1112");
            if (ioi.IsSucceed == false)
            {
                VelocBox1g8.Text = "未接收";
            }
            else
            {
                VelocBox1g8.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1114");
            if (ioi.IsSucceed == false)
            {
                VelocBox2g8.Text = "未接收";
            }
            else
            {
                VelocBox2g8.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1108");
            if (ioi.IsSucceed == false)
            {
                VelocBox3g8.Text = "未接收";
            }
            else
            {
                VelocBox3g8.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1110");
            if (ioi.IsSucceed == false)
            {
                VelocBox4g8.Text = "未接收";
            }
            else
            {
                VelocBox4g8.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1404");
            if (ioi.IsSucceed == false)
            {
                VelocBox5g8.Text = "未接收";
            }
            else
            {
                VelocBox5g8.Text = ioi.Value.ToString();
            }
            //VelocBox1g8.Text = LocalStatic.Plc.Read<float>("1112").Value.ToString();
            //VelocBox2g8.Text = LocalStatic.Plc.Read<float>("1114").Value.ToString();
            //VelocBox3g8.Text = LocalStatic.Plc.Read<float>("1108").Value.ToString();
            //VelocBox4g8.Text = LocalStatic.Plc.Read<float>("1110").Value.ToString();
            //VelocBox5g8.Text = LocalStatic.Plc.Read<float>("1404").Value.ToString();
            ioi = LocalStatic.Plc.Read<float>("1120");
            if (ioi.IsSucceed == false)
            {
                VelocBox1g9.Text = "未接收";
            }
            else
            {
                VelocBox1g9.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1122");
            if (ioi.IsSucceed == false)
            {
                VelocBox2g9.Text = "未接收";
            }
            else
            {
                VelocBox2g9.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1116");
            if (ioi.IsSucceed == false)
            {
                VelocBox3g9.Text = "未接收";
            }
            else
            {
                VelocBox3g9.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1118");
            if (ioi.IsSucceed == false)
            {
                VelocBox4g9.Text = "未接收";
            }
            else
            {
                VelocBox4g9.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1406");
            if (ioi.IsSucceed == false)
            {
                VelocBox5g9.Text = "未接收";
            }
            else
            {
                VelocBox5g9.Text = ioi.Value.ToString();
            }
            //VelocBox1g9.Text = LocalStatic.Plc.Read<float>("1120").Value.ToString();
            //VelocBox2g9.Text = LocalStatic.Plc.Read<float>("1122").Value.ToString();
            //VelocBox3g9.Text = LocalStatic.Plc.Read<float>("1116").Value.ToString();
            //VelocBox4g9.Text = LocalStatic.Plc.Read<float>("1118").Value.ToString();
            //VelocBox5g9.Text = LocalStatic.Plc.Read<float>("1406").Value.ToString();
        }

        
        private void TextBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                try
                {

                    float fait;
                    focusedControl = Keyboard.FocusedElement;
                    //判断是否是自己需要的控件
                    if (focusedControl != null && focusedControl is TextBox)
                    {
                        TextBox tb = (TextBox)focusedControl;
                        if (tb.Text.Contains("-"))
                        {
                            Growl.Error("不能为负数");
                            return;
                        }
                        switch (tb.Name)
                        {
                            case "VelocBox1g1":
                                fait = float.Parse(VelocBox1g1.Text);
                                if (LocalStatic.Plc.Write<float>("1128", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox2g1":
                                fait = float.Parse(VelocBox2g1.Text);
                                if (LocalStatic.Plc.Write<float>("1130", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox3g1":
                                fait = float.Parse(VelocBox3g1.Text);
                                if (LocalStatic.Plc.Write<float>("1124", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox4g1":
                                fait = float.Parse(VelocBox4g1.Text);
                                if (LocalStatic.Plc.Write<float>("1126", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox5g1":
                                fait = float.Parse(VelocBox5g1.Text);
                                if (LocalStatic.Plc.Write<float>("1408", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox1g2":
                                fait = float.Parse(VelocBox1g2.Text);
                                if (LocalStatic.Plc.Write<float>("1136", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox2g2":
                                fait = float.Parse(VelocBox2g2.Text);
                                if (LocalStatic.Plc.Write<float>("1138", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox3g2":
                                fait = float.Parse(VelocBox3g2.Text);
                                if (LocalStatic.Plc.Write<float>("1132", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox4g2":
                                fait = float.Parse(VelocBox4g2.Text);
                                if (LocalStatic.Plc.Write<float>("1134", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox5g2":
                                fait = float.Parse(VelocBox5g2.Text);
                                if (LocalStatic.Plc.Write<float>("1410", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox1g3":
                                fait = float.Parse(VelocBox1g3.Text);
                                if (LocalStatic.Plc.Write<float>("1144", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox2g3":
                                fait = float.Parse(VelocBox2g3.Text);
                                if (LocalStatic.Plc.Write<float>("1146", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox3g3":
                                fait = float.Parse(VelocBox3g3.Text);
                                if (LocalStatic.Plc.Write<float>("1140", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox4g3":
                                fait = float.Parse(VelocBox4g3.Text);
                                if (LocalStatic.Plc.Write<float>("1142", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox5g3":
                                fait = float.Parse(VelocBox5g3.Text);
                                if (LocalStatic.Plc.Write<float>("1412", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox1g4":
                                fait = float.Parse(VelocBox1g4.Text);
                                if (LocalStatic.Plc.Write<float>("1156", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox2g4":
                                fait = float.Parse(VelocBox2g4.Text);
                                if (LocalStatic.Plc.Write<float>("1158", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox3g4":
                                fait = float.Parse(VelocBox3g4.Text);
                                if (fait>1000)
                                {
                                    Growl.Error("数字大于1000");
                                    break;
                                }
                                if (LocalStatic.Plc.Write<float>("1148", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox4g4":
                                fait = float.Parse(VelocBox4g4.Text);
                                if (fait > 1000)
                                {
                                    Growl.Error("数字大于1000");
                                    break;
                                }
                                if (LocalStatic.Plc.Write<float>("1154", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox5g4":
                                fait = float.Parse(VelocBox5g4.Text);
                                if (fait > 1000)
                                {
                                    Growl.Error("数字大于1000");
                                    break;
                                }
                                if (LocalStatic.Plc.Write<float>("1414", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox1g5":
                                fait = float.Parse(VelocBox1g5.Text);
                                if (LocalStatic.Plc.Write<float>("1164", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox2g5":
                                fait = float.Parse(VelocBox2g5.Text);
                                if (LocalStatic.Plc.Write<float>("1166", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox3g5":
                                fait = float.Parse(VelocBox3g5.Text);
                                if (LocalStatic.Plc.Write<float>("1160", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox4g5":
                                fait = float.Parse(VelocBox4g5.Text);
                                if (LocalStatic.Plc.Write<float>("1162", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox5g5":
                                fait = float.Parse(VelocBox5g5.Text);
                                if (LocalStatic.Plc.Write<float>("1416", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox1g6":
                                fait = float.Parse(VelocBox1g6.Text);
                                if (LocalStatic.Plc.Write<float>("1104", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox2g6":
                                fait = float.Parse(VelocBox2g6.Text);
                                if (LocalStatic.Plc.Write<float>("1106", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox3g6":
                                fait = float.Parse(VelocBox3g6.Text);
                                if (LocalStatic.Plc.Write<float>("1100", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox4g6":
                                fait = float.Parse(VelocBox4g6.Text);
                                if (LocalStatic.Plc.Write<float>("1102", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox5g6":
                                fait = float.Parse(VelocBox5g6.Text);
                                if (LocalStatic.Plc.Write<float>("1400", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox1g7":
                                fait = float.Parse(VelocBox1g7.Text);
                                if (LocalStatic.Plc.Write<float>("1604", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox2g7":
                                fait = float.Parse(VelocBox2g7.Text);
                                if (LocalStatic.Plc.Write<float>("1606", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox3g7":
                                fait = float.Parse(VelocBox3g7.Text);
                                if (LocalStatic.Plc.Write<float>("1600", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox4g7":
                                fait = float.Parse(VelocBox4g7.Text);
                                if (LocalStatic.Plc.Write<float>("1602", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox5g7":
                                fait = float.Parse(VelocBox5g7.Text);
                                if (LocalStatic.Plc.Write<float>("1402", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox1g8":
                                fait = float.Parse(VelocBox1g8.Text);
                                if (LocalStatic.Plc.Write<float>("1112", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox2g8":
                                fait = float.Parse(VelocBox2g8.Text);
                                if (LocalStatic.Plc.Write<float>("1114", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox3g8":
                                fait = float.Parse(VelocBox3g8.Text);
                                if (LocalStatic.Plc.Write<float>("1108", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox4g8":
                                fait = float.Parse(VelocBox4g8.Text);
                                if (LocalStatic.Plc.Write<float>("1110", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox5g8":
                                fait = float.Parse(VelocBox5g8.Text);
                                if (LocalStatic.Plc.Write<float>("1404", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox1g9":
                                fait = float.Parse(VelocBox1g9.Text);
                                if (LocalStatic.Plc.Write<float>("1120", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox2g9":
                                fait = float.Parse(VelocBox2g9.Text);
                                if (LocalStatic.Plc.Write<float>("1122", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox3g9":
                                fait = float.Parse(VelocBox3g9.Text);
                                if (LocalStatic.Plc.Write<float>("1116", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox4g9":
                                fait = float.Parse(VelocBox4g9.Text);
                                if (LocalStatic.Plc.Write<float>("1118", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                            case "VelocBox5g9":
                                fait = float.Parse(VelocBox5g9.Text);
                                if (LocalStatic.Plc.Write<float>("1406", fait).IsSucceed == false)
                                {
                                    Growl.Error("上传失败");
                                }
                                break;
                        }
                    }

                }
                catch (Exception ee)
                {
                    Growl.Error(ee.ToString());
                }
            }
        }

        private void loadFirst(object sender, EventArgs e)
        {
            //dispatcherTimer = new DispatcherTimer();
            //dispatcherTimer.Tick += new EventHandler(TimeCycle);
            //dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 1);
            //dispatcherTimer.Start();
            //dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 1000);
            TimeCycle();
        }

        private void VelocButton_Click(object sender, RoutedEventArgs e)
        {
            TimeCycle();
        }

    }
}
